//
// Created by HP on 2022/1/21.
//

#ifndef VULKAN_TUTORIAL_LVE_GAME_OBJECT_H
#define VULKAN_TUTORIAL_LVE_GAME_OBJECT_H

#include "lve_model.h"

//libs
#include <glm/gtc/matrix_transform.hpp>
// std
#include <memory>

namespace lve {

    struct TransformComponent {
        glm::vec3 translation{}; // (position offset)
        glm::vec3 scale{1.f, 1.f, 1.f};
        // rotation.x -> 以 x 轴 为旋转轴旋转 rotation.x (弧度制)
        // 向着 x 正方向看是: 顺时针旋转  顺 ---> +x
        // 以此类推
        glm::vec3 rotation{};

        // https://en.wikipedia.org/wiki/Euler_angles#Rotation_matrix
        glm::mat4 mat4();
        glm::mat3 normalMatrix();
    };

    class LveGameObject {
    public:
        using id_t = unsigned int;

        static LveGameObject createGameObject() {
            static id_t currentId = 0;
            return LveGameObject{currentId++};
        }

        // 删除复制构造
        LveGameObject(const LveGameObject&) = delete;
        LveGameObject& operator=(const LveGameObject&) = delete;
        // 实现移动构造
        LveGameObject(LveGameObject&&) = default;
        LveGameObject& operator=(LveGameObject&&) = default;

        id_t getId() { return id; }

        std::shared_ptr<LveModel> model{};
        glm::vec3 color{};
        TransformComponent transform{};
    private:
        LveGameObject(id_t objId): id(objId) {}

        id_t id;
    };
}

#endif //VULKAN_TUTORIAL_LVE_GAME_OBJECT_H
